package com.tianyuan.dplrf.ui.popup;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TableRow;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.hjq.base.BaseAdapter;
import com.hjq.base.BasePopupWindow;
import com.hjq.base.action.ActivityAction;
import com.hjq.base.action.AnimAction;
import com.tianyuan.dplrf.R;
import com.tianyuan.dplrf.ui.adapter.Ncjt_tianqiAdapter;
import com.tianyuan.dplrf.ui.bean.Ncjt_tianqibean;

import java.util.List;

public class TianqiPop {

    public final static class Builder extends BasePopupWindow.Builder<Builder>
            implements AnimAction {
        private RecyclerView recy;
        List<Ncjt_tianqibean> data;
        Ncjt_tianqiAdapter mAdapter;

        BaseAdapter.OnItemClickListener listener;
        private AppCompatTextView tv_title;
        private TextView tv_reftime;
        private TableRow tabrow;


        public Builder(Context context) {
            super(context);
            setContentView(R.layout.pop_tianqilayout);
            initview();
            mAdapter = new Ncjt_tianqiAdapter(context);

        }

        public void setmAdapter() {
            recy.setLayoutManager(new GridLayoutManager(getContext(),2));
            recy.setAdapter(mAdapter);
        }

        public void setListener(BaseAdapter.OnItemClickListener listener) {
            this.listener = listener;
        }

        public void setData(List<Ncjt_tianqibean> data) {
            this.data = data;
            mAdapter.setData(data);
        }

        private void initview() {
            tv_title = findViewById(R.id.tv_title);
            tv_reftime = findViewById(R.id.tv_reftime);
            tabrow = findViewById(R.id.tabrow);
            recy = findViewById(R.id.recy);

            tv_title.setVisibility(View.GONE);
            tabrow.setVisibility(View.GONE);
        }

        public void setTitleMessage(String title,String refTime){
            tv_title.setVisibility(View.VISIBLE);
            tabrow.setVisibility(View.VISIBLE);
            tv_title.setText(title);
            tv_reftime.setText(refTime);
        }

        public void setDefault(int width, int wrapContent, int scaleAnimStyle) {
            setWidth(width);
            setHeight(wrapContent);
            setAnimStyle(scaleAnimStyle);
        }
    }

}
